package hello;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

public class helloWorld {

	private boolean oddsTurn;

	private Odd oddPrinter;
	private Even evenPrinter;
	private boolean done;

	public helloWorld() {
		oddsTurn = false;
		done = false;

		oddPrinter = new Odd();
		evenPrinter = new Even();

		evenPrinter.start();
		evenPrinter.testMethod();
		oddPrinter.start();
		oddPrinter.testMethod();
		evenPrinter.testMethod();
	}

	private class Odd extends Thread {
		private String constantLetters;
		private int currentLetter;

		public Odd() {
			currentLetter = 0;
			constantLetters = "el ol";
		}

		public void run() {
			while(!done) {
				if (oddsTurn) {
					System.out.print(constantLetters.charAt(currentLetter++));
					oddsTurn = !oddsTurn;
					if(currentLetter >= constantLetters.length()){
						done = true;

					}
				}
			}
		}
		
		public void testMethod() {
			System.out.println("test");
		}
	}

	private class Even extends Thread {
		private String constantLetters;
		private int currentLetter;

		public Even() {
			currentLetter = 0;
			constantLetters = "hlowrd";
		}

		public void run() {
			while(!done) {
				if (!oddsTurn) {
					System.out.print(constantLetters.charAt(currentLetter++));
					oddsTurn = !oddsTurn;
					if(currentLetter >= constantLetters.length()){
						done = true;
					}
				}
			}
		}
		
		public void testMethod() {
			System.out.println("test");
		}
	}
	public static void main(String args[]) {
//		PrintWriter pw = new PrintWriter(System.out);
//		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
//		
//		pw.write('b');
//		pw.flush();
//		
//		pw.write('c');
//		pw.flush();
//		
//		try {
//			System.out.println(br.readLine());
//		} catch (IOException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		}
		
		helloWorld hw = new helloWorld();
	}
}
